package com.weeasy.share.controller;

import com.weeasy.core.common.Result;
import com.weeasy.share.service.ShareService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 微信分享控制器
 * 
 * @author we-easy
 * @since 1.0.0
 */
@RestController
@RequestMapping("/share")
@RequiredArgsConstructor
@CrossOrigin(origins = "*")
public class ShareController {

    private final ShareService shareService;

    /**
     * 分享内容
     * 
     * @param title 分享标题
     * @param description 分享描述
     * @param link 分享链接
     * @return 分享结果
     */
    @PostMapping("/content")
    public Result<String> shareContent(@RequestParam String title, 
                                     @RequestParam String description, 
                                     @RequestParam String link) {
        String result = shareService.shareContent(title, description, link);
        return Result.success("分享成功", result);
    }

    /**
     * 获取分享历史
     * 
     * @return 分享历史
     */
    @GetMapping("/history")
    public Result<String> getShareHistory() {
        String history = shareService.getShareHistory();
        return Result.success("获取分享历史成功", history);
    }
}
